<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>全球中美港股市公司企业市值排名榜</title>
        <meta name="description" content="An interactive getting started guide for Brackets.">
        <link href="https://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap-theme.css" rel="stylesheet">
        <link href="https://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://cdn.bootcss.com/jquery/1.12.1/jquery.min.js"></script>

    </head>
    <body>
        <div class="container">
            <div class="row clearfix">
                <h3 class="text-center text-info">
                        全球中美港股市公司企业市值排名榜
                    </h3>
				 <h5 class="text-center text-info">
                        Zack 出品（http://www.si-lian.cn/zackstock/）
                    </h5>
                <div class="col-md-10 column">
                    
                    <table class="table">
                        <thead>
                            <tr>
                                <th>
                                     排名
                                </th>
                                <th>
                                    企业
                                </th>
                                <th>
                                    市值(亿-x)
                                </th>
								 <th>
                                    市值(亿-$)
                                </th>
								 <th>
                                    市值(亿-CNY)
                                </th>
                                <th>
                                   时间 
                                </th>
                            </tr>
                        </thead>
                        <tbody id="stockTableBody">



                        </tbody>
                    </table>
                </div>
				<div class="col-md-2 column">
                <a>
                    <h4>
                    zack,金融数据
                    </h4>
                    </a>
                </div>
				<div class="row clearfix">
					<div class="col-md-12 column">
						<div id="footer">
							<div class="footerNav">
								 <a href="#">关于我们</a> | <a href="#">服务条款</a> | <a href="#">免责声明</a> | <a href="#">网站地图</a> | <a href="#">联系我们</a>
							</div>
							<div class="copyRight">
								Copyright ©2017-2018 Zack 版权所有 本人是对企业市值比较感兴趣的二把刀技术，制作这个是方便自己，也方便同样兴趣的朋友。大家将就看看。
							</div>
						</div>
						
					</div>
				</div>
				
			
				
            </div>
        </div>
<script>      
    
    var hkexchus=0;
    var hkexchcny=0;
    var cnyexchus=0;
     $.ajax({
        type: "GET",
        url: "get.php?f=HKD&t=CNY",
        dataType: "",
        success: function (data)
        {
            
         hkexchcny=data; 
        },
         error:function (XMLHttpRequest, textStatus, errorThrown) {      
            alert("请求失败！");
        }
     });
        $.ajax({
        type: "GET",
        url: "get.php?f=USD&t=CNY",
        dataType: "",
        success: function (data)
        {
            
         cnyexchus=data; 
        },
         error:function (XMLHttpRequest, textStatus, errorThrown) {      
            alert("请求失败！");
        }
     }); 
     $.ajax({
        type: "GET",
        url: "get.php?f=USD&t=HKD",
        dataType: "",
        success: function (data)
        {
            
         hkexchus=data; 
        },
         error:function (XMLHttpRequest, textStatus, errorThrown) {      
            alert("请求失败！");
        }
     });  
    
var url = "bai.php"; 
    $.ajax({
        type: "GET",
        url: url,
        dataType: "json",
        success: function (data)
        {
            if("true"==data.flag){
               alert("合法！");
                return true;
            }else{
                //alert("不合法！错误信息如下："+data.errorMsg);
				var obj=data.data;
				var bod=null;
				for(var i = 0 ; i < obj.length; i++) {
					var exchus=1;
					var exchcny=1;
						if(obj[i].exchange=='hk')
						{
							exchus=1/hkexchus;
							exchcny=hkexchcny;
						}
						else if(obj[i].exchange=="sz" || obj[i].exchange=="sh")
						{
							exchus=1/cnyexchus;
							exchcny=1;
						}
						else if(obj[i].exchange=="us")
						{
							exchus=1;
							exchcny=cnyexchus;
						}
                        var totalx=Math.round(obj[i].capitalization/1000000)/100;
						var totalus=Math.round(exchus*obj[i].capitalization/1000000)/100;
						var totalcny=Math.round(exchcny*obj[i].capitalization/1000000)/100;
                        var no=i+1;
						bod=bod+"<tr><td>"+no+"</td><td>"+obj[i].stockName+"("+obj[i].exchange+"."+obj[i].stockCode+")</td> <td>"+totalx+"</td><td>"+totalus+"(1:"+Math.round(exchus*10000)/10000+")</td><td>"+totalcny+"(1:"+exchcny+")</td><td>"+new Date().toLocaleDateString()+"</td></tr>";
			    }
				$("#stockTableBody").html(bod);
                return false;
            }
        },
        error:function (XMLHttpRequest, textStatus, errorThrown) {      
            alert("请求失败！");
        }
     });   
        </script>
</body>